package com.czk.springboot.reactive.reactor.sink;

import reactor.core.publisher.Flux;

public class SinkDemo {

    public static void main(String[] args) {
        // 初始值是0
        Flux<Object> flux = Flux.generate(() -> 0, (state, sink) -> {
            if (state > 10) {
                // 大于10就结束流
                sink.complete();
            }
            // 继续往下发送
            sink.next(state);
            // 将新的发送出去
            return state + 1;
        });

        flux.log().subscribe();

    }

}
